import React, { Component } from 'react';
import '../styles/HotArtist.scss'
import * as service from '../api/index'
import { withRouter } from "react-router-dom";

class HotArtist extends Component {
    state = {
        hotartistlist: []
    }
    async componentDidMount() {
        let res = await service.index_hotartistlist()
        // console.log(res.data.list);
        this.setState({ hotartistlist: res.data.list })
    }
    handleClick(){
        this.props.history.push("/artist")
    }
    render() {
        return (
            <div className='hotartist'>
                <div className="option">
                    <div className="title">
                        热门艺人
                    </div>
                    <div className="watch" onClick={()=>{this.handleClick()}}>
                        查看全部
                    </div>
                </div>
                <div className="hotartistlist">
                    {
                        this.state.hotartistlist.map((item, index) => {
                            return (
                                <div className="item">
                                    <img src={item.pic} alt="" />
                                    <div className="name">
                                        {item.name}
                                    </div>
                                </div>
                            )
                        })
                    }
                </div>
            </div>
        );
    }
}

export default withRouter(HotArtist);